#!/bin/sh

LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")

/usr/bin/ssr-check www.google.com 80 3 1

if [ "$?" == "0" ]; then
	echo '['$LOGTIME'] ShadowsocksR No Problem.'
else
	/usr/bin/ssr-check www.baidu.com 80 3 1
	if [ "$?" == "0" ]; then
		echo '['$LOGTIME'] Problem decteted, restarting ShadowsocksR...'
		/etc/init.d/shadowsocksr restart
	else
		echo '['$LOGTIME'] Network Problem. Do nothing.'
	fi
fi
